package com.qiche.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qiche.model.Verification;
import com.qiche.service.VerificationService;

import tk.mybatis.mapper.entity.Example;

/**
 * Created by Linzw on 2018/01/24.
 */
@Service("verificationService")
public class VerificationServiceImpl extends BaseService<Verification> implements VerificationService {

	/*
	 * @Resource private CardMapper mapper;
	 */
	@Override
	public PageInfo<Verification> selectByPage(Verification verification, int start, int length) {
		int page = start / length + 1;
		Example example = new Example(Verification.class);
		Example.Criteria criteria = example.createCriteria();
		// 分页查询
		PageHelper.startPage(page, length);
		List<Verification> verificationList = selectByExample(example);
		return new PageInfo<>(verificationList);
	}

	@Override
	public Verification selectById(Long verificationId) {
		Example example = new Example(Verification.class);
		Example.Criteria criteria = example.createCriteria();
		criteria.andEqualTo("id", verificationId);
		List<Verification>  verificationList = selectByExample(example);
		if (verificationList.size() > 0) {
			return verificationList.get(0);
		}
		return null;
	}

	/*@Override
	public Card selectByCardcode(String cardCode) {
		Example example = new Example(Card.class);
		Example.Criteria criteria = example.createCriteria();
		criteria.andEqualTo("cardCode", cardCode);
		List<Card> cardList = selectByExample(example);
		if (cardList.size() > 0) {
			return cardList.get(0);
		}
		return null;
	}*/

}
